package fr.grobim.hangovers.gestionBudget.actions.tableaux.factures;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import org.springframework.beans.factory.annotation.Autowired;

import fr.grobim.hangovers.gestionBudget.services.factures.FacturationService;
import fr.grobim.hangovers.gestionBudget.actions.enums.AttributsSession;
import fr.grobim.hangovers.gestionBudget.actions.support.AbstractActionSupportAvecTableau;

@Namespace(value = "/")
@ResultPath(value = "/")
public class ListerFacturesAction extends AbstractActionSupportAvecTableau<FactureTableau> {

	private static final long serialVersionUID = 1L;
	
	@Autowired
	private FacturationService factureService;

	@Override
	@Action(value = "remplirListeFactures", results = {
			@Result(type = "json")})
	public String execute() throws Exception {
		List<FactureTableau> listeFactureComplete = getObjectDeSession(AttributsSession.GESTION_FACTURE_LISTE);
		if (listeFactureComplete == null) {
			listeFactureComplete = FactureTableau.convertirListe(factureService.listerToutesFactures());
			getSession().put(AttributsSession.GESTION_FACTURE_LISTE.getClee(), listeFactureComplete);
		}
		setListeTableau(listeFactureComplete);
		return SUCCESS;
	}

	@Override
	public Integer getRows() {
		return super.getRows();
	}

	@Override
	public Integer getPage() {
		return super.getPage();
	}

	@Override
	public String getSord() {
		return super.getSord();
	}

	@Override
	public String getSidx() {
		return super.getSidx();
	}

	@Override
	public String getSearchField() {
		return super.getSearchField();
	}

	@Override
	public String getSearchString() {
		return super.getSearchString();
	}

	@Override
	public String getSearchOper() {
		return super.getSearchOper();
	}

	@Override
	public Integer getTotal() {
		return super.getTotal();
	}

	@Override
	public Integer getRecords() {
		return super.getRecords();
	}

	@Override
	public List<FactureTableau> getListeTableau() {
		return super.getListeTableau();
	}
	
}
